<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>		
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>编辑文章</title>
<link rel="stylesheet" type="text/css" href="../easyui/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css" href="../easyui/themes/icon.css" />
<link rel="stylesheet" type="text/css" href="../css/pop-page.css" />
<script type="text/javascript" src="../easyui/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="../easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../kindeditor/kindeditor-min.js"></script>
<script type="text/javascript" src="../easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
	function initForm(){
		$('#fm').form({
			url : "../article/updateArticle.do",  
		    onSubmit: function(){
		        var at = $("#at").combobox("getValue");
		        if(at == "-1"){
		        	$.messager.alert("提示",'<br />请选择文章类型！','info');
		        	return false;
		        }
		        var title = $("#title").val();
		        if($.trim(title) == ""){
		        	$.messager.alert("提示",'<br />请填写文章标题！','info');
		        	return false;
		        }
		        $("#hidCon").val( editor.html() );
		        return true;
		    }, 
		    success:function(msg){
		        if("success" == msg){
		        	parent.reloadDg();
		        } else {
		        	$.messager.alert('Warning','<br />' + msg);
		        }
		    }
		});  
	}
	
	$(function(){
		initForm();
		initArticleTypeCombo();
		initEditor();
	});
	
	function initArticleTypeCombo(){
		$('#at').combobox({
		    url:'../articleType/initArticleTypeCombo.do',
		    panelHeight: 'auto',
		    onLoadSuccess: function(){
		    	$("#at").combobox('setValue', <s:property value="article.articleType.id"/>);
		    }
		});
	}
	
	var editor;
	
	function initEditor() {
		KindEditor.ready(function(K) {
			editor = K.create('#content', {
				resizeType : 1,
				allowPreviewEmoticons : false,
				allowImageUpload : false,
				newlineTag : 'br',
				width : '700px',
				height : '300px',
				items :[
			        'undo', 'redo', '|', 'preview', 'template', 'code', 'cut', 'copy', 'paste',
			        'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
			        'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
			        'superscript', 'clearhtml', 'quickformat', 'selectall', '/',
			        'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
			        'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 
			        'table', 'hr', 'emoticons', 'pagebreak','anchor', 'link', 'unlink',
				]
			});
		});
	}
</script>
</head>
<body class="easyui-layout">
	<div data-options="region:'center',border:false">
		<form id="fm" method="post">
			<input type="hidden" name="article.id" value='<s:property value="article.id"/>'/>
			<input type="hidden" id="hidCon" name="article.content" />
			<div class="dg-content">
				<table cellspacing="8px">
					<tr>
						<td align="right" style="padding-right: 5px;width: 60px">类型</td>
						<td>
							<select class="easyui-combobox" id="at" name="article.articleType.id" 
								style="width: 150px">
							</select>
							<font color="red">&nbsp;*</font>
						</td>
					</tr>
					<tr>
						<td align="right" style="padding-right: 5px;width: 60px">标题</td>
						<td><input type='text' id="title" name="article.title" class='in-text' 
								style="width: 400px" value='<s:property value="article.title"/>'/>
							<font color="red">&nbsp;*</font>
						</td>
					</tr>
					<tr>
						<td align="right" style="padding-right: 5px;width: 60px;vertical-align: top;">正文</td>
						<td>
							<textarea id="content"><s:property value="article.content"/></textarea>
						</td>
					</tr>
				</table>
			</div>
		</form>
	</div>
	<div data-options="region:'south'" class='fm-btn'>
		<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="$('#fm').submit();">保存</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="parent.closeWin()">取消</a>
	</div>
</body>
</html>